package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo4 {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入类名:>");
        String name = scanner.nextLine();
        System.out.print("请输入方法名:>");
        String methodName = scanner.nextLine();
        Class<?> c = Class.forName(name);
        Object o = c.newInstance();
        Method method = c.getMethod(methodName);
        method.invoke(o);
    }
}